package cn.tedu.tmall.basic.dao.persist.repository.impl;

import cn.tedu.tmall.basic.dao.persist.mapper.DistrictMapper;
import cn.tedu.tmall.basic.dao.persist.repository.IDistrictRepository;
import cn.tedu.tmall.common.pojo.po.DistrictSimplePO;
import cn.tedu.tmall.common.pojo.vo.PageData;
import cn.tedu.tmall.common.util.PageInfoToPageDataConverter;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class DistrictRepository implements IDistrictRepository {
    @Autowired
    DistrictMapper mapper;

    @Override
    public List<DistrictSimplePO> listByParent(Long parentId) {
        return mapper.listByParent(parentId);
    }

    @Override
    public PageData<DistrictSimplePO> list(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<DistrictSimplePO> list = mapper.list();
        PageInfo<DistrictSimplePO> pageInfo=new PageInfo<>(list);
        return PageInfoToPageDataConverter.convert(pageInfo);
    }

}
